package tr.edu.ege.kipler.syntax.atomicformula;

import tr.edu.ege.kipler.syntax.Role;
import tr.edu.ege.kipler.syntax.WorldElementVisitor;

/**
 * 
 * @author İnanç Seylan
 *
 */
public class RoleAssertion extends Formula {
	public enum Type {
		TRANSITIVE;
	}

	private Type type;

	private Role role;

	public RoleAssertion() {

	}

	public RoleAssertion(Type type, Role role) {
		setType(type);
		setRole(role);
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public Type getType() {
		return type;
	}

	public void setType(Type type) {
		this.type = type;
	}

	public RoleAssertion toggleNegated() {
		return this;
	}

	public boolean isNegated() {
		return false;
	}

	public void accept(WorldElementVisitor v) {
		v.visitRoleAssertion(this);
	}

	@Override
	public boolean equals(Object obj) {
		if (obj != null && (obj.getClass().equals(this.getClass()))) {
			RoleAssertion other = (RoleAssertion) obj;
			return (getType().equals(other.getType()) && getRole().equals(
					other.getRole()));
		}
		return false;
	}

	@Override
	public int hashCode() {
		return 17 * 37 + getType().hashCode() + getRole().hashCode();
	}

	public RoleAssertion copy() {
		RoleAssertion ra = new RoleAssertion();
		ra.setType(getType());
		ra.setRole(getRole().copy());
		return ra;
	}

	@Override
	public String toString() {
		StringBuffer buffer = new StringBuffer();
		buffer.append(getType());
		buffer.append("(");
		buffer.append(getRole());
		buffer.append(")");
		return buffer.toString();
	}

}
